const Service = require('../../../core/service/ApiService');

class UserSvc extends Service{

    //家长登录
    async parentLogin(pInfo) {
        const dao = this.service.mobile.user.dao;
        const userInfo = await dao.findInfoByNumber(pInfo.child_number);
        if(!admin)
            throw new this.error.BusinessError('该学号不错在，请确认学号是否准确');
        if(userInfo.parent_mobile!==pInfo.parent_mobile)
            throw new this.error.BusinessError('该手机号有误，请确认后重新输入');
        this.ctx.session.parent_mobile = userInfo.parent_mobile;
    }

    //学生端登录
    async studentLogin(sInfo) {
        const dao =  this.service.mobile.user.dao;
        const stuInfo = await dao.findStudentInfoByNumber(sInfo.user_number);
        if(!stuInfo)
            throw new this.error.BusinessError('该学号有误，请确认后重新输入');
        const encryptedPwd = this.helper.sha1(sInfo.password);
        if(encryptedPwd!==stuInfo.password)
            throw new this.error.BusinessError('密码错误');


    }

}


module.exports = UserSvc;
